package com.ellricky.teacher.ui.mycourse.leave

import android.view.View
import com.ellricky.baselib.cache.LocalCacheUtil
import com.ellricky.baselib.http.HttpUtils
import com.ellricky.baselib.ui.base.BaseDetailActivity
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.baselib.util.NewEntityCallback
import com.ellricky.teacher.API_LEAVE_CANCEL
import com.ellricky.teacher.R
import kotlinx.android.synthetic.main.tc_activity_leave_detail.*
import java.util.*

class LeaveDetailActivity : BaseDetailActivity() {

    override fun getContentLayout(): Int {
        return R.layout.tc_activity_leave_detail
    }

    override fun initUIView() {
        super.initUIView()
        mTvTitle.text = getString(R.string.tc_leave_detail)
        btnCancel.setOnClickListener(this)

        loadDetailData(id)
    }


    override fun onClickView(v: View?) {
        super.onClickView(v)
        when (v) {
            btnCancel -> mPresenter.sendBackRequest(API_LEAVE_CANCEL, id)
        }
    }

    private fun loadDetailData(id: String) {

        val paramMap = HashMap<String, String>()
        val url = EAppUtil.getApiHost()
        paramMap["action"] = "teacherSchoolList"
        paramMap["eid"] = LocalCacheUtil.getUid()

        HttpUtils.getInstance()
            .postFrom(url, paramMap, object : NewEntityCallback<String>(this, false) {
                override fun onSuccess(var1: String?, var2: String?) {

                }
            })
//        mPresenter.loadDetail(API_LEAVE_DETAIL, id, object : ECallback<TcLeaveDetailEntity>(this) {
//            override fun onSuccess(data: TcLeaveDetailEntity?, msg: String) {
//
//                data?.let {
//
//                    GlideUtil.into(this@LeaveDetailActivity, it.headPic, ivAvatar)
//                    tvUserName.text = it.name
//
//                    tvSchoolArea.value = it.areaName
//                    tvFzClass.value = it.className
//                    tvLeaveDate.value = it.leaveDate
//                    tcLeaveTime.value = it.leaveTime
//                    tvLeaveType.value = it.leaveType
//                    tvLeaveReason.value = it.leaveReason
//                    tvTempTeacher.value = it.changeTeacherName
//
//                    if (it.approveStatus != "1") {
//                        btnCancel.visibility = GONE;
//                    } else {
//                        btnCancel.visibility = VISIBLE;
//                    }
//                }
//            }
//        })
    }
}